Repository navigation
feat(workflow-code): workflows as code - #10128
waleedlatif1 wants to merge 479 commits into
Conversation
- runtime and real-catalog seeds build blocks with createBlock, whose subBlocks take list values - the parity catalog is built from its one input - json-field-refs uses createExecutorContext instead of casting a partial context - lock fixtures carry parent: null, and the corpus types the print through typeof printWorkflow
The printer leaves out params that never execute, but compile filled every omitted param with its editor default. A stored block without a value for an inactive defaulted field (a function block's tool-input secretScope) then diffed as modified, so get then apply of unchanged source wrote, audited and notified instead of answering a no-op. For a block the stored workflow holds, a default-filled inactive param now takes the stored value, or none.
…race A second waiter on the workflow row queues on the first waiter's tuple lock, so Postgres reports it blocked by that waiter, not the holder, and the direct count never reached two.
user_table_def_workspace_name_unique refuses two live tables with one name, so the fixtures differ only in what the key drops (case, punctuation).
…eport env - folder paths are percent-encoded, as the canonical path rule requires (CR-02, CR-03 got 400) - the report path reads WORKFLOW_SOURCE_APPLY_E2E_REPORT_PATH, not the sibling suite's variable - add the test:workflow-source-apply:e2e script
The panel is server-rendered, so a click before hydration had no handler and the tab never opened. Click until the tab shows.
…pply restoreInactive copied prev's value into every param that is inactive under the compiled values. A standalone advanced-mode field is active only while it holds a value, so deleting it or writing '' made it inactive, prev's value came back and ran again. Restore only an id that stays inactive with prev's value plugged in.
…t values in source apply
…y identity compileToolList resolved a tool's stored() params from the stored tool at the same list index, so deleting or reordering tools handed one tool's secret to its neighbour with no diagnostic. Resolve stored() after the whole list compiles: the one stored tool of the same type and operation whose params agree with every param source writes wins; otherwise a lone candidate wins while the kind's count is unchanged, and position decides only while the list keeps its stored shape. Anything else is ambiguous and refused with E_STORED_VALUE_MISSING.
Canonicalize marks a row with no stored title as titleMissing, but the printer and compile dropped it, so a no-op apply wrote the positional title. For the last row that is 'else', which the executor matches by title: a condition with no fallback gained an unconditional one. Print such a row as branches meta title: null and compile title: null back to titleMissing; the SDK meta type allows null. No golden holds such a row, so printed bytes are unchanged.
…puts as inactive isInactive called every undeclared id on a custom block active, but the serializer drops them whenever the block declares an input (customBlockHasDeclaredInputs): a deleted input's stale value. Mirror that rule, with the serializer's RESERVED_PARAMS as the structural ids, so the stale value leaves meta.extra and source again holds what executes.
… code files the source uses
…ource resources manifest
…a workflow's not-addable types
…nvas edit and keep the plan's targeted layout
…, and write the full tree on create - server answers may only name workflow.ts and functions/<name>.<js|py|sh> - get --dir refuses another workflow's directory and unapplied edits (tracked in .sim/written.json) unless --force - tsconfig.json carries a marker; one without it is never replaced - the declaration cache keys on the generator line (cli release and core.d.ts hash) beside the catalog header - readSourceText strips a byte-order mark; a 413 on get exits 7 - create writes the sdk declarations, tsconfig.json and agents guide; the guide shows the header and workflow skeleton and links the docs
…e port Two halves of one mismatch. The printer wrote an edge in its source's scope, so a raw edge from a container into one of its children named the child outside the callback that declares it and compile refused the file. Print each edge in the deepest scope that sees both ends. And compile read a subflow handle as the start or end port on any block, while canonicalize does so only on a container of the handle's own kind: a parallel's legacy 'loop-start-source' edge came back as parallel-start-source. Read handles with parseWorkflowSourceHandle, as canonicalize does. No golden holds such an edge, so printed bytes are unchanged.
…piler accepts
The compiler reads workflow('Name', () => { ... }) with no options, but
core.d.ts required options, so tsc refused that form with TS2554. Add an
overload so types and compiler accept the same two forms. The printer
keeps writing the three-argument form, which both accept. rag-doc-qa, an
example with no options, now uses the short form so the type-check and
the example compile both exercise it.
Also correct the README: create writes the full tree a get writes (the
.sim/sdk types, tsconfig.json, .sim/AGENTS.md and the lock files), and
.sim/AGENTS.md is the authoring guide linking the docs.
…g the 409 SOURCE_NAME_TAKEN
…he feature workflows as code
Resolving stored() after the list compiles appended the kept value to the tool's params, so a secret written before other params moved last and print(compile(print(c))) was no longer byte-identical. Hold the param's place with a placeholder that the identity match ignores.
A tool with no builder form printed raw(tool) verbatim, password params
included, so a pasted API key reached Copilot and the Code tab although
source never prints a secret. Print a password param holding literal text
as params: { key: stored() } (an alias-spelled key counts when its param
is a password), and compile a direct stored() entry of a raw tool's
params through the same identity match as a builder tool, in its written
place. No golden holds a secret in a raw tool, so printed bytes are
unchanged.
…ialize unliftValue copied a value's members with result[key] = ..., so a literal __proto__ key in a JSON field, own data in the canonical model, set the stored object's prototype instead and was lost on write. Use setOwn there, and in the same copy loops over source-controlled keys: a tool's params and extra fields, and a branch row's extra fields.
In the record form the key names the field, but an entry's own name was
copied over it, so { subject: { name: 'other' } } stored a field called
other. Compile now refuses a name that differs from the key, and the
record key always stays the stored name.
…ndex parseStoredPath read an index from any character after a segment, so <a[0]x3]> parsed as a[0][3] and a code file rewrote it to another path.
Branch extra was spread over the stored row last, so an extra id, title, value or key replaced the row's own: the stored id no longer matched the edge handles and the lock, and a value replaced the condition. Compile now refuses those fields (and editor state, which canonicalize drops) in extra.
…alias validateSdkNames checked blocks, methods and triggers by hand and missed the oauthCredential/triggerCredentials alias the generator adds, so --check passed on a file the generator would change. It now reports everything extendSdkNames would add.
The recording value bag trapped get, has and ownKeys but not getOwnPropertyDescriptor, so a thunk that tested a key with Object.hasOwn or hasOwnProperty.call looked value-independent and was frozen as a constant.
…toggles A container resize and a handle toggle copy the edge array without changing an edge, and the draft subscription compared edges by identity, so each read the source again; the handle-toggle operations were also missing from the geometry operations. Edges are now compared by element and both toggle operations count as geometry.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 477 files
Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
Turn on auto-fix | Re-trigger cubic
… the tree A node with more children than one call takes as arguments (a wide array literal) threw a RangeError from the spread, in both compile's literal check and the client's codeFile() scan.
…ormat characters as suspicious The printer escapes and compile warns through one definition, which missed U+061C, U+180E, U+2060-U+2064, U+206A-U+206F and U+FEFF.
…type A bare number, boolean, null or array, or a record without a string type, compiled to a field with no type. The SDK types each entry as a type string or a spec with type, so compile now reports it.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 477 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
Turn on auto-fix | Re-trigger cubic
…ed name, not heap order The blocks query has no ORDER BY, so a colliding pair loads in heap order. Any UPDATE to the first-inserted row (or an insert straddling a page into FSM space) puts it after its namesake, which then keeps the bare key and the assertion on blockKey 'score1~2' fails. A dot-free name beats a dotted one in either order.
…nly recheck The edges read has no ORDER BY, so the evaluation read and the row-locked re-read can return the same edges in different orders (an in-place row rewrite, or a seq scan vs. an index scan on workflow_id + source/target). The layout-only recheck compared the arrays with isEqual and answered a spurious 409 for an unchanged draft. Sort both sides by edge id before comparing. Also give the legacy ~n secret test a dotted loser name: the get's own migration write-back rewrites the two rows one at a time, and an apply that read between them assigned the colliding keys the other way, moving the fingerprint.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 477 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
Turn on auto-fix | Re-trigger cubic
Summary
Workflows as code: a workflow can be read as typed TypeScript and applied back, so agents and developers can build and edit workflows with an editor,
tsc, git review and a dry-run diff instead of the canvas or raw operation batches.@sim/workflow-code: compiler (TypeScript → canonical model), printer (canonical model → TypeScript), materializer (canonical model → stored graph, preserving block ids through a lock file), diagnostics withfile:lineframes and hints, size and depth limits.@sim/workflow-sdk: the typed SDK generated from the block catalog (agent,condition,table.queryRows,trigger.schedule, …), per-workspace resource types (table('tickets'),credential('slack'),skill('tone'),customTool('lookup')), and a verified cookbook example. An agent'sskillsprint asskill('key')and write back as{ skillId, name }.GET/POST /api/v2/workflows/{id}/source,POST /api/v2/workspaces/{id}/workflows/source(create), the source catalog and resources manifest. Every route goes through an authorized application use case; writes are rate limited (sourceWrite), refuse workspace API keys, and answer 409 when the draft changed since the read.sim workflows source get | create | applywith--dry-run,--yes, a generated.sim/AGENTS.md, and stable exit codes.{"summary": "<agent.content>"}in a Response block or table row data) is now JSON-escaped. Before, any value with a newline or quote broke the JSON, so the Response block returned the body as a plain string and table inserts failed.Everything is behind the global
workflow-codefeature flag (off by default).Type of Change
Testing
Reviewers: the executor change in
apps/sim/executor/variables/resolver.tsis the one behaviour change outside the flag.Checklist